package com.tang.trap.listener;

import java.util.Vector;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.snmp4j.CommandResponder;
import org.snmp4j.CommandResponderEvent;
import org.snmp4j.smi.VariableBinding;

/**
 * @author tangfl
 */
public class ListenSnmp implements CommandResponder {

	public Logger logger = LoggerFactory.getLogger(getClass());
	
	public ListenSnmp() {
		logger.debug("监控器初始debug");
		logger.info("监控器初始info");
		logger.warn("监控器初始warn");
		logger.error("监控器初始error");
	}
	
	@Override
	public void processPdu(CommandResponderEvent event) {

		 // 解析Response
        if (event != null && event.getPDU() != null) {
            Vector<? extends VariableBinding> recVBs = event.getPDU().getVariableBindings();
            for (int i = 0; i < recVBs.size(); i++) {
                VariableBinding recVB = recVBs.elementAt(i);
                logger.error(recVB.getOid() + " : " + recVB.getVariable());
                System.out.println(recVB.getOid() + " : " + recVB.getVariable());
            }
        }
		
	}

}

